﻿@{
    ViewBag.Title = ViewBag.ID != 0 ? "编辑动态" : "添加动态";
}
<h3>@(ViewBag.ID != 0 ? "编辑动态" : "添加动态")</h3>
<div style="padding-left:50px;">
    <hr />
        <table class="tb" style="padding:5px;width:500px;">
            <tbody>
                <tr>
                    <td align="center"><span>动态所属项目：</span></td>
                    <td><span>@ViewBag.PName</span></td>
                </tr>
                <tr>
                    <td align="center"><span>动态标题：</span></td>
                    <td>
                        <textarea rows="2" cols="20" id="txtHDTBT" style="height:110px;width:300px;" maxlength="100">@Model.DTBT</textarea>(100)
                    </td>
                </tr>
                <tr>
                    <td align="center"><span>链接地址：</span></td>
                    <td><input type="text" id="txtDTDZ" style="width:300px;" value ="@Model.DTDZ"></td>
                </tr>
                <tr>
                    <td align="center"><span>发布时间：</span></td>
                    <td><input type="text" id="txtFBSJ" class="txt" onfocus="WdatePicker()" value="@Model.FBSJ"></td>
                </tr>
            </tbody>
        </table>
    <hr />
    <table style="text-align :center;width:500px;">
        <tbody>
            <tr>
                <td>
                    <input type="button" value="@(ViewBag.ID != 0 ? "编辑" : "添加")" id="btnAdd" style="width:60px;">
                    <input type="button" value="返回" id="btnReturn" onclick="javascript: window.history.go(-1);" style="width:60px;">
                </td>
            </tr>
        </tbody>
    </table>
    <hr />
</div>
<script src='http://t.szhome.com/Style/public/plug-in/My97DatePicker/WdatePicker.js'></script>
<script type="text/javascript">
    $("#btnAdd").bind("click", function () {
        edit();
    });

    function edit() {
        var txtHDTBT = $("#txtHDTBT").val();
        var txtDTDZ = $("#txtDTDZ").val();
        var txtFBSJ = $("#txtFBSJ").val();

        if (txtHDTBT == "") {
            dlg.Msg.Inf("标题不能为空");
            return;
        }
        if (txtDTDZ == "") {
            dlg.Msg.Inf("链接地址不能为空");
            return;
        }
        if (txtFBSJ == "") {
            dlg.Msg.Inf("发布时间不能为空");
            return;
        }
        $.ajax({
            type: "post",
            url: "/manage/news/json_edit",
            data: {
                DTID : @ViewBag.ID,
                XMID : @ViewBag.PID,
                DTBT : txtHDTBT,
                DTDZ : txtDTDZ,
                FBSJ : txtFBSJ
            },
            dataType: "json",
            timeout: 30000, //over time：30s
            beforeSend: function () {
                window.top.qibu.msgbox.loading("正在提交申请，请稍后... ...");
            },
            success: function (data) {
                window.top.qibu.msgbox.hide();
                if (data) {
                    dlg.Msg.Inf("操作成功");
                    setTimeout("window.history.go(-1)", 1000);
                }
                else {
                    dlg.Msg.Err("操作失败");
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                window.top.qibu.msgbox.hide();
                dlg.Msg.Err(errorThrown);
            }
        });
    }
</script>